<div th:fragment="add">
    <div class="modal fade myDivClass" id="myModal1"   tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel"></h4>
                </div>
                <form id ="contentForm">
                <div class="modal-body">
                    <div class="form-group">
                        <label  class="control-label">标题:</label>
                        <input type="text" autocomplete="off"  class="form-control" placeholder="请输入标题"   name="title1">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">需求描述:</label>
                        <input type="text" class="form-control" autocomplete="off" placeholder="请输入需求描述"  value=""  name="demandDescribe1">
                    </div>

                    <div class="form-group">
                        <label  class="control-label">技术要求:</label>
                        <input type="text" class="form-control" autocomplete="off" placeholder="请输入技术要求"  value=""  name="technology1">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">预计时长:</label>
                        <input type="number" class="form-control" autocomplete="off" placeholder="请输入预计时长"  value=""  name="estimateDuration1">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">赏金:</label>
                        <input type="number" class="form-control" autocomplete="off" placeholder="请输入赏金"  value=""  name="moneyReward1">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">联系人:</label>
                        <input type="text" class="form-control"  autocomplete="off" placeholder="请输入联系人"    name="contactName1">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">联系人手机号:</label>
                        <input type="number" class="form-control"  autocomplete="off" placeholder="请输入联系人手机号"    name="contactNumber1">
                    </div>
                </div>

                </form>
                <div class="modal-footer">
                    <button id="add" type="button" class="myDivClass btn btn-success">确定</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>

            </div>
        </div>
    </div>
    <script>
        $('#myModal1').on('hidden.bs.modal', function () {
            $('#Id').html('');
        });
        $('#myModal1').on('hidden.bs.modal', function (){
            document.getElementById("contentForm").reset();
        });
        //点击新增按钮弹出框
        $("#btn_add").click(function () {
            $("#myModalLabel").text("发布需求");
            $('#myModal1').modal();
        });
        //点击保存按钮
        $("#add").click(function(){
            const title = $("input[name='title1']").val();//获取表单form1的用户名的值
            const demandDescribe = $("input[name='demandDescribe1']").val();//获取表单form1密码值
            const technology = $("input[name='technology1']").val();//获取表单form1密码值
            const estimateDuration = $("input[name='estimateDuration1']").val();//获取表单form1密码值estimated_duration
            const moneyReward = $("input[name='moneyReward1']").val();//获取表单form1密码值
            const contactName = $("input[name='contactName1']").val();//获取表单form1密码值
            const contactNumber = $("input[name='contactNumber1']").val();//获取表单form1密码值
            if ((title == "") || (title == null)) {//判断用户名是否为空，为空就弹出提示框"请输入用户名"，否则正常执行下面的代码。
                toastr.error("请输入标题！");
                return false;
            } else if ((demandDescribe == "") || (demandDescribe == null)) {//判断密码是否为空，为空就弹出提示框"请输入密码"，否则正常执行下面的代码。
                toastr.error("请输入内容！");
                return false;
            }
            const data = {
                title: title,
                demandDescribe: demandDescribe,
                technology: technology,
                estimatedDuration: estimateDuration,
                moneyReward: moneyReward,
                contactName: contactName,
                contactNumber:contactNumber
            };
            //提交后台保存用户数据
            myrequest("/admin/demand/add",data,'POST',function(data){
                $('#myModal1').modal('hide')
                toastr.success(data.msg);
                $("#table").bootstrapTable('refresh');
            }, function(data){
                toastr.error(data.msg);
            })
        });

    </script>

</div>